home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / include / g++ / stdexcept < prev    next >
Encoding:
Text File  |  1998-12-04  |  2.9 KB  |  102 lines

  1. // Methods for Exception Support for -*- C++ -*-
  2. // Copyright (C) 1994, 1995, 1997 Free Software Foundation
  3.  
  4. // This file is part of the GNU ANSI C++ Library.  This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 2, or (at your option)
  8. // any later version.
  9.  
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this library; see the file COPYING.  If not, write to the Free
  17. // Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. // As a special exception, if you link this library with files
  20. // compiled with a GNU compiler to produce an executable, this does not cause
  21. // the resulting executable to be covered by the GNU General Public License.
  22. // This exception does not however invalidate any other reasons why
  23. // the executable file might be covered by the GNU General Public License.
  24.  
  25. // Written by Mike Stump based upon the specification in the 20 September 1994
  26. // C++ working paper, ANSI document X3J16/94-0158.
  27.  
  28. #ifndef __STDEXCEPT__
  29. #define __STDEXCEPT__
  30.  
  31. #ifdef __GNUG__
  32. #pragma interface "stdexcept"
  33. #endif
  34.  
  35. #include <exception>
  36. #include <string>
  37.  
  38. extern "C++" {
  39.  
  40. #ifdef __HONOR_STD
  41. namespace std {
  42. #endif
  43.  
  44. class logic_error : public exception {
  45.   string _what;
  46. public:
  47.   logic_error(const string& what_arg): _what (what_arg) { }
  48.   virtual const char* what () const { return _what.c_str (); }
  49. };
  50.  
  51. class domain_error : public logic_error {
  52. public:
  53.   domain_error (const string& what_arg): logic_error (what_arg) { }
  54. };
  55.  
  56. class invalid_argument : public logic_error {
  57. public:
  58.   invalid_argument (const string& what_arg): logic_error (what_arg) { }
  59. };
  60.  
  61. class length_error : public logic_error {
  62. public:
  63.   length_error (const string& what_arg): logic_error (what_arg) { }
  64. };
  65.  
  66. class out_of_range : public logic_error {
  67. public:
  68.   out_of_range (const string& what_arg): logic_error (what_arg) { }
  69. };
  70.  
  71. class runtime_error : public exception {
  72.   string _what;
  73. public:
  74.   runtime_error(const string& what_arg): _what (what_arg) { }
  75.   virtual const char* what () const { return _what.c_str (); }
  76. protected:
  77.   runtime_error(): exception () { }
  78. };
  79.  
  80. class range_error : public runtime_error {
  81. public:
  82.   range_error (const string& what_arg): runtime_error (what_arg) { }
  83. };
  84.  
  85. class overflow_error : public runtime_error {
  86. public:
  87.   overflow_error (const string& what_arg): runtime_error (what_arg) { }
  88. };
  89.  
  90. class underflow_error : public runtime_error {
  91. public:
  92.   underflow_error (const string& what_arg): runtime_error (what_arg) { }
  93. };
  94.  
  95. #ifdef __HONOR_STD
  96. } // namespace std
  97. #endif
  98.  
  99. } // extern "C++"
  100.  
  101. #endif
  102.